<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改</title>
    <link rel="stylesheet" href="../../css/pintuer.css">
    <link rel="stylesheet" href="../../css/admin.css">
    <link rel="stylesheet" href="../../css/bootstrap.css">
    <style>
        input{
            border-top: none;
            border-left: none;
            border-right: none;
            border-bottom: black solid 1px;
        }
        table{
            border: 1px;
            cell-padding:0;
            cell-spacing:0;
            width: 80%;
            margin-top: 20px;
        }
        table thead{
            background-color:#b3d7ff ;
        }
        a{
            cursor: pointer;
        }
    </style>
</head>
<body>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/bootstrap.min.js"></script>
<script src="../../js/bootstrap-table1.15.3.js"></script>
<script>
    function init(){
        $.ajax({
            url:'/dFile/selectByDelete.action',
            type:'post',
            data: 'tag=C001-0',
            dataType:'json',
            success:function (data) {
                var tb = $('#tb_com');
                tb.empty();
                for( var i=0;i<data.length;i++){
                    var tr=$("<tr>");

                    var PID = $("<td>");
                    var a = $("<a href='../product.html?pid="+data[i].PRODUCT_ID+"'>").text(data[i].PRODUCT_ID);
                    PID.append(a);
                    tr.append(PID);


                    var pname =$("<td>").text(data[i].PRODUCT_NAME);
                    tr.append(pname);

                    var type = $('<td>').text(data[i].TYPE==="Y001-1"?"商品":"物料");
                    tr.append(type);

                    var itype = $('<td>').text(data[i].FIRST_KIND_NAME);
                    tr.append(itype);

                    var iitype = $("<td>").text(data[i].SECOND_KIND_NAME);
                    tr.append(iitype);

                    var iiitype = $("<td>").text(data[i].THIRD_KIND_NAME);
                    tr.append(iiitype);

                    var resperson = $("<td>").text(data[i].RESPONSIBL_PERSON);
                    tr.append(resperson);

                    var t = $("<td>");
                    var a = $("<a style='color: #33bbdd;'>").text("删除");
                    a.attr("onclick","btn("+data[i].ID+");");
                    t.append(a);
                    tr.append(t);


                    tb.append(tr);

                }
            }
        })
    }
    $(function () {
      init();

    })
    function btn(id) {
        var r = confirm("您确定要删除该产品档案吗？");
        if(r){
            $.ajax({
            url:'/dFile/changeDelete',
            data: 'id='+id+'&tag=C001-1',
            dataType: 'json',
            type: 'get',
            success:function (data) {
                if (data>0){
                    init();
                }else{
                    alert("删除失败");
                }
            }
        });
        }
    }
</script>
<table style="text-align: center;" class="table table-bordered table-hover table-striped table-condensed">
    <thead>
    <tr>
        <th>产品编号</th>
        <th>产品名称</th>
        <th>用途类型</th>
        <th>I级分类</th>
        <th>II级分类</th>
        <th>III级分类</th>
        <th>产品经理</th>
        <th>删除</th>
    </tr>
    </thead>
    <tbody id="tb_com">
    </tbody>
</table>
</body>
</html>